home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / AppsToGo / AppsToGo.src / DTS.Lib / ViewHierarchy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-18  |  26.0 KB  |  998 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** Program:     DTS.Lib
  5. ** File:        viewhierarchy.c
  6. ** Written by:  Eric Soldan
  7. **
  8. ** Copyright © 1990-1993 Apple Computer, Inc.
  9. ** All rights reserved.
  10. */
  11.  
  12. /* You may incorporate this sample code into your applications without
  13. ** restriction, though the sample code has been provided "AS IS" and the
  14. ** responsibility for its operation is 100% yours.  However, what you are
  15. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  16. ** after having made changes. If you're going to re-distribute the source,
  17. ** we require that you make it clear in the source that the code was
  18. ** descended from Apple Sample Code, but that you've made changes. */
  19.  
  20.  
  21.  
  22. /*****************************************************************************/
  23.  
  24.  
  25.  
  26. #include "DTS.Lib2.h"
  27. #include "DTS.Lib.protos.h"
  28.  
  29. #ifndef __CTLHANDLER__
  30. #include "CtlHandler.h"
  31. #endif
  32.  
  33. #ifndef __ERRORS__
  34. #include <Errors.h>
  35. #endif
  36.  
  37. #ifndef __FONTS__
  38. #include <Fonts.h>
  39. #endif
  40.  
  41. #ifndef __LISTCONTROL__
  42. #include "ListControl.h"
  43. #endif
  44.  
  45. #ifndef __RESOURCES__
  46. #include <Resources.h>
  47. #endif
  48.  
  49. #ifndef __STDIO__
  50. #include <StdIO.h>
  51. #endif
  52.  
  53. #ifndef __STRING__
  54. #include <String.h>
  55. #endif
  56.  
  57. #ifndef THINK_C
  58. #ifndef __STRINGS__
  59. #include <Strings.h>
  60. #endif
  61. #endif
  62.  
  63. #ifndef __TEXTEDITCONTROL__
  64. #include "TextEditControl.h"
  65. #endif
  66.  
  67.  
  68.  
  69. /*****************************************************************************/
  70.  
  71.  
  72.  
  73. typedef struct ViewHierFileTypeRec {
  74.     FileStateRec    fileState;
  75.     ConnectRec        connect;
  76.     ViewDoc            vh;
  77. } ViewHierFileTypeRec;
  78.  
  79.  
  80. extern short    gTECtl;
  81. extern short    gListCtl;
  82.  
  83. extern short            gPrintPage;            /* Non-zero means we are printing. */
  84. extern TreeObjProcPtr    gTreeObjMethods[];
  85. extern Cursor            *gCursorPtr;
  86. extern TreeObjHndl        gWindowFormats;
  87.  
  88. static void        VHContentClick(WindowPtr window, EventRecord *event, Boolean firstClick);
  89. static Boolean    VHContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough);
  90. static OSErr    VHImageDocument(FileRecHndl frHndl);
  91. static OSErr    VHInitContent(FileRecHndl frHndl, WindowPtr window);
  92. static Boolean    VHDisplayFilter(TEHandle teHndl, EventRecord *event, short *handled);
  93. static void        VHNewView(FileRecHndl frHndl, char *newText, short newTextLen, Boolean updatePList);
  94. static OSErr    VHUpdateInfo(FileRecHndl frHndl, Boolean updatePList);
  95. static Boolean    VHWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt);
  96.  
  97.  
  98.  
  99. /*****************************************************************************/
  100. /*****************************************************************************/
  101.  
  102.  
  103.  
  104. /* This is called when a mouse-down event occurs in the content of a window.
  105. ** Other applications might want to call FindControl, TEClick, etc., to
  106. ** further process the click. */
  107.  
  108. #pragma segment Window
  109. void    VHContentClick(WindowPtr window, EventRecord *event, Boolean firstClick)
  110. {
  111. #pragma unused (firstClick)
  112.  
  113.     FileRecHndl        frHndl;
  114.     ControlHandle    ctl;
  115.     short            ctlNum, action, len, selStart;
  116.     ListHandle        plist, clist;
  117.     TEHandle        te, display;
  118.     char            newText[33];
  119.     Point            cell;
  120.  
  121.     frHndl = (FileRecHndl)GetWRefCon(window);
  122.  
  123.     ctlNum = IsCtlEvent(window, event, &ctl, &action);
  124.     switch (ctlNum) {
  125.         case 101:
  126.             display = (*frHndl)->d.vh.display;
  127.             te = CTEFindActive(window);
  128.             if (!te)
  129.                 te = display;
  130.             ctl = CTEViewFromTE(te);
  131.             if (te == display) {
  132.                 CTEActivate(true, te);
  133.                 CLActivate(false, CLFindActive(window));
  134.                 CTESetSelect(0, (*te)->teLength, display);
  135.             }
  136.             len = (*te)->selEnd - (selStart = (*te)->selStart);
  137.             if (len > 32)
  138.                 len = 32;
  139.             BlockMove(*((*te)->hText) + selStart, newText, len);
  140.             VHNewView(frHndl, newText, len, true);
  141.             break;
  142.         case 102:
  143.             if (action == 1) {
  144.                 plist = (*frHndl)->d.vh.plist;
  145.                 cell  = LLastClick(plist);
  146.                 len   = 8;
  147.                 LGetCell(newText, &len, cell, plist);
  148.                 VHNewView(frHndl, newText, len, false);
  149.             }
  150.             break;
  151.         case 103:
  152.             if (action == 1) {
  153.                 clist = (*frHndl)->d.vh.clist;
  154.                 cell  = LLastClick(clist);
  155.                 len   = 8;
  156.                 LGetCell(newText, &len, cell, clist);
  157.                 VHNewView(frHndl, newText, len, true);
  158.             }
  159.             break;
  160.     }
  161. }
  162.  
  163.  
  164.  
  165. /*****************************************************************************/
  166.  
  167.  
  168.  
  169. /* This is called when a key event occurs and it is determined that it isn't
  170. ** a menu key. */
  171.  
  172. #pragma segment Window
  173. Boolean    VHContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough)
  174. {
  175. #pragma unused (passThrough)
  176.  
  177.     FileRecHndl        frHndl;
  178.     char            key;
  179.     ControlHandle    ctl;
  180.     short            action, selStart, len;
  181.     TEHandle        te, display;
  182.     char            newText[33];
  183.  
  184.     frHndl = (FileRecHndl)GetWRefCon(window);
  185.     key = event->message & charCodeMask;
  186.  
  187.     if ((key == chEnter) || (key == chReturn)) {
  188.         SelectButton(ctl = (*frHndl)->d.vh.newView);
  189.         display = (*frHndl)->d.vh.display;
  190.         te = CTEFindActive(window);
  191.         if (!te)
  192.             te = display;
  193.         ctl = CTEViewFromTE(te);
  194.         if (te == display) {
  195.             CTEActivate(true, te);
  196.             CLActivate(false, CLFindActive(window));
  197.             CTESetSelect(0, (*te)->teLength, display);
  198.         }
  199.         len = (*te)->selEnd - (selStart = (*te)->selStart);
  200.         if (len > 32)
  201.             len = 32;
  202.         BlockMove(*((*te)->hText) + selStart, newText, len);
  203.         VHNewView(frHndl, newText, len, true);
  204.         return(true);
  205.     }
  206.  
  207.     return(IsCtlEvent(window, event, &ctl, &action));
  208. }
  209.  
  210.  
  211.  
  212. /*****************************************************************************/
  213.  
  214.  
  215.  
  216. /* Image the document into the current port. */
  217.  
  218. #pragma segment Window
  219. OSErr    VHImageDocument(FileRecHndl frHndl)
  220. {
  221. #pragma unused (frHndl)
  222.  
  223.     WindowPtr        curPort;
  224.  
  225.     GetPort(&curPort);
  226.  
  227.     if (!gPrintPage) {                                        /* If not printing... */
  228.         DoDrawControls(curPort, false);                        /* Draw the content controls. */
  229.         OutlineControl((*frHndl)->d.vh.newView);
  230.     }
  231.     else {
  232.         gPrintPage = 0;
  233.     }
  234.  
  235.     return(noErr);
  236. }
  237.  
  238.  
  239.  
  240. /*****************************************************************************/
  241.  
  242.  
  243.  
  244. /* This function does the remaining window initialization. */
  245.  
  246. #pragma segment Window
  247. OSErr    VHInitContent(FileRecHndl frHndl, WindowPtr window)
  248. {
  249.     FileRecPtr        frPtr;
  250.     FileRecHndl        refFrHndl;
  251.     WindowPtr        oldPort;
  252.     ControlHandle    ctl;
  253.     TEHandle        dump, display;
  254.     ListHandle        plist, clist;
  255.     ControlHandle    newView;
  256.     OSErr            err;
  257.  
  258.     GetPort(&oldPort);
  259.     SetPort(window);
  260.  
  261.     if (err = AddControlSet(window, (*frHndl)->fileState.sfType, kwStandardVis, 0, 0, nil))
  262.         return(err);
  263.  
  264.     CNum2Ctl(window, 100, &ctl);
  265.     dump = (TEHandle)GetCRefCon(ctl);
  266.  
  267.     CNum2Ctl(window, 101, &ctl);
  268.     display = (TEHandle)GetCRefCon(ctl);
  269.     CTESetKeyFilter(display, VHDisplayFilter);
  270.  
  271.     CNum2Ctl(window, 102, &ctl);
  272.     plist = (ListHandle)GetCRefCon(ctl);
  273.  
  274.     CNum2Ctl(window, 103, &ctl);
  275.     clist = (ListHandle)GetCRefCon(ctl);
  276.  
  277.     CNum2Ctl(window, 104, &newView);
  278.  
  279.     frPtr = *frHndl;
  280.     frPtr->d.vh.dump    = dump;
  281.     frPtr->d.vh.display = display;
  282.     frPtr->d.vh.plist   = plist;
  283.     frPtr->d.vh.clist   = clist;
  284.     frPtr->d.vh.newView = newView;
  285.  
  286.     refFrHndl = mDerefRoot(frPtr->d.vh.root)->frHndl;
  287.     NewWindowTitle(window, (*refFrHndl)->fileState.fss.name);
  288.     VHUpdateInfo(frHndl, true);
  289.  
  290.     SetPort(oldPort);
  291.     return(noErr);
  292. }
  293.  
  294.  
  295.  
  296. /*****************************************************************************/
  297.  
  298.  
  299.  
  300. #pragma segment Window
  301. static Boolean    VHWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt)
  302. {
  303. #pragma unused (frHndl, window, globalPt)
  304.  
  305.     SetCursor(gCursorPtr = &qd.arrow);
  306.     return(true);
  307. }
  308.  
  309.  
  310.  
  311. /*****************************************************************************/
  312.  
  313.  
  314.  
  315. #pragma segment Window
  316. Boolean    VHDisplayFilter(TEHandle teHndl, EventRecord *event, short *handled)
  317. {
  318. #pragma unused (teHndl, handled)
  319.     char    key;
  320.     short    arrowKey;
  321.  
  322.     key = event->message & charCodeMask;
  323.     arrowKey = ((key >= chLeft) && (key <= chDown));
  324.     if (
  325.         (arrowKey) ||
  326.         (key == chBackspace) ||
  327.         (key == chTab) ||
  328.         ((key >= '0') && (key <= '9')) ||
  329.         ((key >= 'A') && (key <= 'F')) ||
  330.         ((key >= 'a') && (key <= 'f'))
  331.     ) {
  332.         return(false);
  333.     }
  334.  
  335.     return(true);
  336. }
  337.  
  338.  
  339.  
  340. /*****************************************************************************/
  341.  
  342.  
  343.  
  344. /* This function adds the application's controls to a window. */
  345.  
  346. #pragma segment Window
  347. void    VHNewView(FileRecHndl frHndl, char *newText, short newTextLen, Boolean updatePList)
  348. {
  349.     TEHandle    te;
  350.     short        len, i;
  351.     long        newHndl;
  352.     char        workText[33];
  353.  
  354.     if (!newText) {
  355.         newText    = workText;
  356.         newTextLen = 0;
  357.     }
  358.     if (!(len = newTextLen)) {
  359.         te = (*frHndl)->d.vh.display;
  360.         BlockMove(*((*te)->hText), newText, len = (*te)->teLength);
  361.     }
  362.  
  363.     for (newHndl = 0, i = 0; i < len; ++i) {
  364.         if ((newText[i] >= '0') && (newText[i] <= '9')) {
  365.             newHndl *= 16;
  366.             newHndl += (newText[i] - '0');
  367.             continue;
  368.         }
  369.         if ((newText[i] >= 'a') && (newText[i] <= 'f'))
  370.             newText[i] -= 32;
  371.         if ((newText[i] >= 'A') && (newText[i] <= 'F')) {
  372.             newHndl *= 16;
  373.             newHndl += (newText[i] - 'A' + 10);
  374.         }
  375.     }
  376.  
  377.     if (newHndl) {
  378.         GetHandleSize((Handle)newHndl);
  379.         if (!MemError()) {
  380.             (*frHndl)->d.vh.root = (TreeObjHndl)newHndl;
  381.             VHUpdateInfo(frHndl, updatePList);
  382.         }
  383.         else SysBeep(1);
  384.     }
  385. }
  386.  
  387.  
  388.  
  389. /*****************************************************************************/
  390.  
  391.  
  392.  
  393. /* This function adds the application's controls to a window. */
  394.  
  395. #pragma segment Window
  396. OSErr    VHUpdateInfo(FileRecHndl frHndl, Boolean updatePList)
  397. {
  398.     WindowPtr        oldPort;
  399.     TreeObjHndl        root, chndl, phndl;
  400.     TEHandle        dump;
  401.     ListHandle        plist, clist;
  402.     Handle            text;
  403.     char            *cptr, *kcptr;
  404.     long            dataSize, x, v;
  405.     short            *dptr, cnum, depth, ctype;
  406.     Point            cell;
  407.     char            ctext[32], ptext[32];
  408.     RgnHandle        rgn;
  409.     Boolean            customFormat;
  410.     TreeObjProcPtr    proc;
  411.     VHFormatData    cf;
  412.  
  413.     root  = (*frHndl)->d.vh.root;
  414.     dump  = (*frHndl)->d.vh.dump;
  415.     plist = (*frHndl)->d.vh.plist;
  416.     clist = (*frHndl)->d.vh.clist;
  417.  
  418.     DoNumberTree(root);
  419.  
  420.     text = NewHandle(32767);
  421.     if (!text)
  422.         return(MemError());
  423.  
  424.     GetPort(&oldPort);
  425.     SetPort((*frHndl)->fileState.window);
  426.  
  427.     HLock(text);
  428.     cptr = kcptr = StripAddress(*text);
  429.  
  430.     ccpy   (cptr, "$");
  431.     ccathex(cptr, '0', 8, 8, (long)root);
  432.     ccatchr(cptr, 13, 2);
  433.  
  434.     ccat   (cptr, "$00:        type = $");
  435.     ccathex(cptr, '0', 4, 4, ctype = (*root)->type);
  436.     ccatchr(cptr, 13, 1);
  437.  
  438.     ccat   (cptr, "$02: numChildren = $");
  439.     ccathex(cptr, '0', 4, 4, (*root)->numChildren);
  440.     ccatchr(cptr, 13, 1);
  441.  
  442.     ccat   (cptr, "$04:    dataSize = $");
  443.     ccathex(cptr, '0', 8, 8, dataSize = (*root)->dataSize);
  444.     ccatchr(cptr, 13, 1);
  445.  
  446.     ccat   (cptr, "$08:      treeID = $");
  447.     ccathex(cptr, '0', 8, 8, (*root)->treeID);
  448.     ccatchr(cptr, 13, 1);
  449.  
  450.     ccat   (cptr, "$0C:      parent = $");
  451.     ccathex(cptr, '0', 8, 8, (long)(*root)->parent);
  452.  
  453.     customFormat = false;
  454.     if (proc = gTreeObjMethods[ctype]) {        /* If this object type has a proc...   */
  455.         cptr     += clen(cptr);
  456.         cf.text   = text;
  457.         cf.header = kcptr;
  458.         cf.data   = cptr;
  459.         customFormat = (*proc)(root, VHMESSAGE, (long)&cf);
  460.         HLock(text);
  461.         cptr = kcptr = StripAddress(*text);
  462.         cptr += clen(cptr);
  463.     }
  464.  
  465.     if (!customFormat) {
  466.         dptr = (short *)GetDataPtr(root);
  467.         for (x = 0; (cptr += clen(cptr)), (x < dataSize); x += sizeof(short)) {
  468.             v = *dptr++;
  469.             v &= 0x0000FFFF;
  470.             if ((dataSize - x) == 1) {
  471.                 v >>= 8;
  472.                 v  &= 0x00FF;
  473.             }
  474.             if (!(x & 0x3F)) {
  475.                 ccatchr(cptr, 13, 2);
  476.                 ccat   (cptr, "$");
  477.                 ccathex(cptr, '0', 8, 8, x + sizeof(TreeObj));
  478.                 ccat   (cptr, ":");
  479.             }
  480.             if (!(x & 0x0F)) {
  481.                 ccatchr(cptr, 13, 1);
  482.                 ccat   (cptr, " ");
  483.             }
  484.             ccat   (cptr, " ");
  485.             if ((dataSize - x) == 1)
  486.                 ccathex(cptr, '0', 2, 2, v);
  487.             else
  488.                 ccathex(cptr, '0', 4, 4, v);
  489.             if ((cptr - kcptr) > 32000) break;
  490.         }
  491.     }
  492.  
  493.     HUnlock(text);
  494.     SetHandleSize(text, cptr - kcptr);
  495.  
  496.     UseControlStyle(CTEViewFromTE(dump));
  497.     DisposeHandle(CTESwapText(dump, text, nil, true));
  498.     UseControlStyle(nil);
  499.  
  500.     UseControlStyle(CLViewFromList(clist));
  501.     LDelRow(0, 0, clist);
  502.     LDoDraw(false, clist);
  503.     cell.h = cell.v = 0;
  504.     for (cnum = (*root)->numChildren; cnum;) {
  505.         chndl = GetChildHndl(root, --cnum);
  506.         ccpyhex(ctext, '0', 8, 8, (long)chndl);
  507.         LAddRow(1, 0, clist);
  508.         LSetCell(ctext, 8, cell, clist);
  509.     }
  510.     LDoDraw(true, clist);
  511.     rgn = NewRgn();
  512.     GetClip(rgn);
  513.     LUpdate(rgn, clist);
  514.     DisposeRgn(rgn);
  515.     UseControlStyle(nil);
  516.  
  517.     UseControlStyle(CLViewFromList(plist));
  518.     if (updatePList) {
  519.         LDelRow(0, 0, plist);
  520.         LDoDraw(false, plist);
  521.         cell.h = cell.v = 0;
  522.         for (depth = 0, phndl = root; phndl; phndl = (*phndl)->parent, ++depth) {
  523.             ccpyhex(ptext, '0', 8, 8, (long)phndl);
  524.             LAddRow(1, 0, plist);
  525.             LSetCell(ptext, 8, cell, plist);
  526.         }
  527.         cell.v = depth - 1;
  528.         LSetSelect(true, cell, plist);
  529.         LAutoScroll(plist);
  530.         LDoDraw(true, plist);
  531.         rgn = NewRgn();
  532.         GetClip(rgn);
  533.         LUpdate(rgn, plist);
  534.         DisposeRgn(rgn);
  535.     }
  536.     else LAutoScroll(plist);
  537.     UseControlStyle(nil);
  538.  
  539.     SetPort(oldPort);
  540.     return(noErr);
  541. }
  542.  
  543.  
  544.  
  545. /*****************************************************************************/
  546. /*****************************************************************************/
  547.  
  548.  
  549.  
  550. #pragma segment Window
  551. OSErr    VHInitDocument(FileRecHndl frHndl)
  552. {
  553.     FileRecPtr    frPtr;
  554.     FileRecHndl    refFrHndl;
  555.     WindowPtr    window;
  556.  
  557.     frPtr = *frHndl;
  558.     if (!gWindowFormats) {
  559.         frPtr->fileState.windowID   = rVHWindow;
  560.         frPtr->fileState.attributes = kwVHAppWindow;
  561.     }
  562.     frPtr->fileState.calcFrameRgnProc        = nil;
  563.     frPtr->fileState.contentClickProc        = VHContentClick;
  564.     frPtr->fileState.contentKeyProc          = VHContentKey;
  565.     frPtr->fileState.drawFrameProc           = nil;
  566.     frPtr->fileState.freeDocumentProc        = nil;
  567.     frPtr->fileState.freeWindowProc          = nil;
  568.     frPtr->fileState.imageProc               = VHImageDocument;
  569.     frPtr->fileState.initContentProc         = VHInitContent;
  570.     frPtr->fileState.readDocumentProc        = nil;
  571.     frPtr->fileState.readDocumentHeaderProc  = nil;
  572.     frPtr->fileState.resizeContentProc       = nil;
  573.     frPtr->fileState.scrollFrameProc         = nil;
  574.     frPtr->fileState.undoFixupProc           = nil;
  575.     frPtr->fileState.windowCursorProc        = VHWindowCursor;
  576.     frPtr->fileState.writeDocumentProc       = nil;
  577.     frPtr->fileState.writeDocumentHeaderProc = nil;
  578.         /* View Hierarchy method declarations. */
  579.  
  580.     /* Document-specific fields are already initialized to 0, so we do nothing. */
  581.  
  582.     for (window = nil; window = GetNextWindow(window, 0);) {
  583.         if (!((WindowPeek)window)->visible) continue;
  584.         if (refFrHndl = (FileRecHndl)GetWRefCon(window)) {
  585.             if ((*refFrHndl)->fileState.defaultDoc) {
  586.                 (*frHndl)->d.vh.root = (*refFrHndl)->d.vh.root;
  587.                     /* This view hierarchy window, which isn't created yet, will reference
  588.                     ** the data in the topmost window that uses the default document
  589.                     ** architecture.  As the view hierarchy window is only for debugging
  590.                     ** purposes, there is no prevision to guarantee that the data being
  591.                     ** pointed to will continue to exist or continue to be valid.
  592.                     ** The document that this references could be closed, and therefore
  593.                     ** the reference would point to non-existent data.  (You are warned.) */
  594.                 return(noErr);
  595.             }
  596.         }
  597.     } 
  598.  
  599.     return(memFullErr);
  600.         /* Memory really isn't full.  We just need to pass back an error so that
  601.         ** the application knows that the view hierarchy document wasn't successfully
  602.         ** created.  It wasn't successfull created because it couldn't find any documents
  603.         ** that use the document hierarchy.  This really shouldn't occur, as the application
  604.         ** shouldn't have the menu option available for the view hierarchy window if there
  605.         ** is nothing to view.  However, since the view hierarchy window is just for
  606.         ** debugging, it seems annoying to demand that the application set the state of
  607.         ** the menu item correctly.  Returning any error here should be enough for the
  608.         ** application to be graceful. */
  609. }
  610.  
  611.  
  612.  
  613. /*****************************************************************************/
  614.  
  615.  
  616.  
  617. #pragma segment Window
  618. long    VHFileTypeSize(void)
  619. {
  620.     return(sizeof(ViewHierFileTypeRec));
  621. }
  622.  
  623.  
  624.  
  625. /*****************************************************************************/
  626.  
  627.  
  628.  
  629. #pragma segment Window
  630. void    VHRootInfo(TreeObjHndl root, char *cptr)
  631. {
  632.     ccat   (cptr, "$10: TRootObj:");
  633.     ccatchr(cptr, 13, 1);
  634.     ccat   (cptr, "  $00: undo        = $");
  635.     ccathex(cptr, '0', 8, 8, (long)mDerefUndo(root)->root);
  636.     ccatchr(cptr, 13, 1);
  637.     ccat   (cptr, "  $04: frHndl      = $");
  638.     ccathex(cptr, '0', 8, 8, (long)mDerefUndo(root)->frHndl);
  639.     ccatchr(cptr, 13, 1);
  640. }
  641.  
  642.  
  643.  
  644. /*****************************************************************************/
  645.  
  646.  
  647.  
  648. #pragma segment Window
  649. void    VHFileRecInfo(TreeObjHndl root, char *cptr)
  650. {
  651.     FileRecHndl    frHndl;
  652.     Str255        str;
  653.     char        hstate;
  654.     Rect        rct;
  655.     long        offset;
  656.  
  657.     frHndl = mDerefRoot(root)->frHndl;
  658.     hstate = LockHandleHigh((Handle)frHndl);
  659.  
  660.     ccat   (cptr, "(*frHndl)->fileState:");
  661.     ccatchr(cptr, 13, 1);
  662.     ccat   (cptr, "  sfType                  = '");
  663.     *(long *)str = (*frHndl)->fileState.sfType;
  664.     str[sizeof(long)] = 0;
  665.     ccat   (cptr, (char *)str);
  666.     ccat   (cptr, "'");
  667.     ccatchr(cptr, 13, 1);
  668.  
  669.     ccat   (cptr, "  defaultDoc              = ");
  670.     ccatdec(cptr, (*frHndl)->fileState.defaultDoc);
  671.     ccatchr(cptr, 13, 1);
  672.  
  673.     ccat   (cptr, "  movie                   = $");
  674.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.movie);
  675.     ccatchr(cptr, 13, 1);
  676.  
  677.     ccat   (cptr, "  movieResID              = ");
  678.     ccatdec(cptr, (*frHndl)->fileState.movieResID);
  679.     ccatchr(cptr, 13, 1);
  680.  
  681.     ccat   (cptr, "  movieFlags              = $");
  682.     ccathex(cptr, '0', 4, 4, (*frHndl)->fileState.movieFlags);
  683.     ccatchr(cptr, 13, 1);
  684.  
  685.     ccat   (cptr, "  movieDataRefWasChanged  = ");
  686.     ccatdec(cptr, (*frHndl)->fileState.movieDataRefWasChanged);
  687.     ccatchr(cptr, 13, 1);
  688.  
  689.     ccat   (cptr, "  docDirty                = ");
  690.     ccatdec(cptr, (*frHndl)->fileState.docDirty);
  691.     ccatchr(cptr, 13, 1);
  692.  
  693.     ccat   (cptr, "  modNum                  = ");
  694.     ccatdec(cptr, (*frHndl)->fileState.modNum);
  695.     ccatchr(cptr, 13, 1);
  696.  
  697.     ccat   (cptr, "  modTick                 = ");
  698.     ccatdec(cptr, (*frHndl)->fileState.modTick);
  699.     ccatchr(cptr, 13, 1);
  700.  
  701.     ccat   (cptr, "  readOnly                = ");
  702.     ccatdec(cptr, (*frHndl)->fileState.readOnly);
  703.     ccatchr(cptr, 13, 1);
  704.  
  705.     ccat   (cptr, "  refNum                  = ");
  706.     ccatdec(cptr, (*frHndl)->fileState.refNum);
  707.     ccatchr(cptr, 13, 1);
  708.  
  709.     ccat   (cptr, "  resRefNum               = ");
  710.     ccatdec(cptr, (*frHndl)->fileState.resRefNum);
  711.     ccatchr(cptr, 13, 1);
  712.  
  713.     ccat   (cptr, "  fss.vRefNum             = ");
  714.     ccatdec(cptr, (*frHndl)->fileState.fss.vRefNum);
  715.     ccatchr(cptr, 13, 1);
  716.  
  717.     ccat   (cptr, "  fss.parID               = $");
  718.     ccathex(cptr, '0', 8, 8, (*frHndl)->fileState.fss.parID);
  719.     ccatchr(cptr, 13, 1);
  720.  
  721.     ccat   (cptr, "  fss.name                = ");
  722.     pcpy   (str, (*frHndl)->fileState.fss.name);
  723.     p2c    (str);
  724.     ccat   (cptr, (char *)str);
  725.     ccatchr(cptr, 13, 1);
  726.  
  727.     ccat   (cptr, "  windowID                = ");
  728.     ccatnum(cptr, (*frHndl)->fileState.windowID, 10);
  729.     ccatchr(cptr, 13, 1);
  730.  
  731.     ccat   (cptr, "  window                  = $");
  732.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.window);
  733.     ccatchr(cptr, 13, 1);
  734.  
  735.     cptr += clen(cptr);
  736.  
  737.     ccat   (cptr, "  getDocWindow            = $");
  738.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.getDocWindow);
  739.     ccatchr(cptr, 13, 1);
  740.  
  741.     ccat   (cptr, "  calcFrameRgnProc        = $");
  742.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.calcFrameRgnProc);
  743.     ccatchr(cptr, 13, 1);
  744.  
  745.     ccat   (cptr, "  contentClickProc        = $");
  746.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.contentClickProc);
  747.     ccatchr(cptr, 13, 1);
  748.  
  749.     ccat   (cptr, "  contentKeyProc          = $");
  750.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.contentKeyProc);
  751.     ccatchr(cptr, 13, 1);
  752.  
  753.     ccat   (cptr, "  drawFrameProc           = $");
  754.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.drawFrameProc);
  755.     ccatchr(cptr, 13, 1);
  756.  
  757.     ccat   (cptr, "  freeDocumentProc        = $");
  758.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.freeDocumentProc);
  759.     ccatchr(cptr, 13, 1);
  760.  
  761.     ccat   (cptr, "  freeWindowProc          = $");
  762.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.freeWindowProc);
  763.     ccatchr(cptr, 13, 1);
  764.  
  765.     ccat   (cptr, "  imageProc               = $");
  766.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.imageProc);
  767.     ccatchr(cptr, 13, 1);
  768.  
  769.     ccat   (cptr, "  initContentProc         = $");
  770.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.initContentProc);
  771.     ccatchr(cptr, 13, 1);
  772.  
  773.     ccat   (cptr, "  readDocumentProc        = $");
  774.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.readDocumentProc);
  775.     ccatchr(cptr, 13, 1);
  776.  
  777.     ccat   (cptr, "  readDocumentHeaderProc  = $");
  778.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.readDocumentHeaderProc);
  779.     ccatchr(cptr, 13, 1);
  780.  
  781.     ccat   (cptr, "  resizeContentProc       = $");
  782.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.resizeContentProc);
  783.     ccatchr(cptr, 13, 1);
  784.  
  785.     ccat   (cptr, "  scrollFrameProc         = $");
  786.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.scrollFrameProc);
  787.     ccatchr(cptr, 13, 1);
  788.  
  789.     ccat   (cptr, "  undoFixupProc           = $");
  790.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.undoFixupProc);
  791.     ccatchr(cptr, 13, 1);
  792.  
  793.     ccat   (cptr, "  windowCursorProc        = $");
  794.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.windowCursorProc);
  795.     ccatchr(cptr, 13, 1);
  796.  
  797.     ccat   (cptr, "  writeDocumentProc       = $");
  798.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.writeDocumentProc);
  799.     ccatchr(cptr, 13, 1);
  800.  
  801.     ccat   (cptr, "  writeDocumentHeaderProc = $");
  802.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.writeDocumentHeaderProc);
  803.     ccatchr(cptr, 13, 1);
  804.  
  805.     ccat   (cptr, "  adjustMenuItemsProc     = $");
  806.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.adjustMenuItemsProc);
  807.     ccatchr(cptr, 13, 1);
  808.  
  809.     ccat   (cptr, "  doMenuItemProc          = $");
  810.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.doMenuItemProc);
  811.     ccatchr(cptr, 13, 1);
  812.  
  813.     cptr += clen(cptr);
  814.  
  815.     ccat   (cptr, "  attributes              = $");
  816.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.attributes);
  817.     ccatchr(cptr, 13, 1);
  818.  
  819.     ccat   (cptr, "  windowSizeBounds        = ($");
  820.     rct = (*frHndl)->fileState.windowSizeBounds;
  821.     ccathex(cptr, 0, 4, 4, rct.top);
  822.     ccat   (cptr, ",$");
  823.     ccathex(cptr, 0, 4, 4, rct.left);
  824.     ccat   (cptr, ",");
  825.     ccatchr(cptr, 13, 1);
  826.     ccatchr(cptr, ' ', 29);
  827.     ccat   (cptr, "$");
  828.     ccathex(cptr, 0, 4, 4, rct.bottom);
  829.     ccat   (cptr, ",$");
  830.     ccathex(cptr, 0, 4, 4, rct.right);
  831.     ccat   (cptr, ")");
  832.     ccatchr(cptr, 13, 1);
  833.  
  834.     ccat   (cptr, "  hScroll                 = $");
  835.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.hScroll);
  836.     ccatchr(cptr, 13, 1);
  837.  
  838.     ccat   (cptr, "  vScroll                 = $");
  839.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->fileState.vScroll);
  840.     ccatchr(cptr, 13, 1);
  841.  
  842.     ccat   (cptr, "  hScrollIndent           = ");
  843.     ccatdec(cptr, (*frHndl)->fileState.hScrollIndent);
  844.     ccatchr(cptr, 13, 1);
  845.  
  846.     ccat   (cptr, "  vScrollIndent           = ");
  847.     ccatdec(cptr, (*frHndl)->fileState.vScrollIndent);
  848.     ccatchr(cptr, 13, 1);
  849.  
  850.     ccat   (cptr, "  leftSidebar             = ");
  851.     ccatdec(cptr, (*frHndl)->fileState.leftSidebar);
  852.     ccatchr(cptr, 13, 1);
  853.  
  854.     ccat   (cptr, "  topSidebar              = ");
  855.     ccatdec(cptr, (*frHndl)->fileState.topSidebar);
  856.     ccatchr(cptr, 13, 1);
  857.  
  858.     ccat   (cptr, "  hArrowVal               = ");
  859.     ccatdec(cptr, (*frHndl)->fileState.hArrowVal);
  860.     ccatchr(cptr, 13, 1);
  861.  
  862.     ccat   (cptr, "  vArrowVal               = ");
  863.     ccatdec(cptr, (*frHndl)->fileState.vArrowVal);
  864.     ccatchr(cptr, 13, 1);
  865.  
  866.     ccat   (cptr, "  hPageVal                = ");
  867.     ccatdec(cptr, (*frHndl)->fileState.hPageVal);
  868.     ccatchr(cptr, 13, 1);
  869.  
  870.     ccat   (cptr, "  vPageVal                = ");
  871.     ccatdec(cptr, (*frHndl)->fileState.vPageVal);
  872.     ccatchr(cptr, 13, 2);
  873.  
  874.     cptr += clen(cptr);
  875.  
  876.     ccat   (cptr, "(*frHndl)->connect:");
  877.     ccatchr(cptr, 13, 1);
  878.     ccat   (cptr, "  windowTag[0]             = ");
  879.     ccatdec(cptr, (*frHndl)->connect.windowTag[0]);
  880.     ccatchr(cptr, 13, 1);
  881.  
  882.     ccat   (cptr, "  windowTag[1]             = ");
  883.     ccatdec(cptr, (*frHndl)->connect.windowTag[1]);
  884.     ccatchr(cptr, 13, 1);
  885.  
  886.     ccat   (cptr, "  connected                = ");
  887.     ccatdec(cptr, (*frHndl)->connect.connected);
  888.     ccatchr(cptr, 13, 1);
  889.  
  890.     ccat   (cptr, "  remoteLoc.descriptorType = '");
  891.     *(long *)str = (*frHndl)->connect.remoteLoc.descriptorType;
  892.     str[sizeof(long)] = 0;
  893.     ccat   (cptr, (char *)str);
  894.     ccat   (cptr, "'");
  895.     ccatchr(cptr, 13, 1);
  896.  
  897.     ccat   (cptr, "  remoteLoc.dataHandle     = $");
  898.     ccathex(cptr, '0', 8, 8, (long)(*frHndl)->connect.remoteLoc.dataHandle);
  899.     ccatchr(cptr, 13, 1);
  900.  
  901.     ccat   (cptr, "  remoteName    = ");
  902.     pcpy   (str, (*frHndl)->connect.remoteName);
  903.     p2c    (str);
  904.     ccat   (cptr, (char *)str);
  905.     ccatchr(cptr, 13, 1);
  906.  
  907.     ccat   (cptr, "  remoteZone    = ");
  908.     pcpy   (str, (*frHndl)->connect.remoteZone);
  909.     p2c    (str);
  910.     ccat   (cptr, (char *)str);
  911.     ccatchr(cptr, 13, 1);
  912.  
  913.     ccat   (cptr, "  remoteMachine = ");
  914.     pcpy   (str, (*frHndl)->connect.remoteMachine);
  915.     p2c    (str);
  916.     ccat   (cptr, (char *)str);
  917.     ccatchr(cptr, 13, 2);
  918.  
  919.     cptr += clen(cptr);
  920.  
  921.     ccat   (cptr, "(*frHndl)->d.doc.fhInfo:");
  922.     ccatchr(cptr, 13, 1);
  923.     ccat   (cptr, "  version       = ");
  924.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.version);
  925.     ccatchr(cptr, 13, 1);
  926.  
  927.     ccat   (cptr, "  printRecValid = ");
  928.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.printRecValid);
  929.     ccatchr(cptr, 13, 1);
  930.  
  931.     ccat   (cptr, "  print         = (char *)(*frHndl) + $");
  932.     offset  = (long)StripAddress(&(*frHndl)->d.doc.fhInfo.print);
  933.     offset -= (long)StripAddress(*frHndl);
  934.     ccathex(cptr, '0', 4, 4, (long)offset);
  935.     ccatchr(cptr, 13, 1);
  936.  
  937.     ccat   (cptr, "  structureRect = ($");
  938.     rct = (*frHndl)->d.doc.fhInfo.structureRect;
  939.     ccathex(cptr, 0, 4, 4, rct.top);
  940.     ccat   (cptr, ",$");
  941.     ccathex(cptr, 0, 4, 4, rct.left);
  942.     ccat   (cptr, ",$");
  943.     ccathex(cptr, 0, 4, 4, rct.bottom);
  944.     ccat   (cptr, ",$");
  945.     ccathex(cptr, 0, 4, 4, rct.right);
  946.     ccat   (cptr, ")");
  947.     ccatchr(cptr, 13, 1);
  948.  
  949.     ccat   (cptr, "  contentRect   = ($");
  950.     rct = (*frHndl)->d.doc.fhInfo.contentRect;
  951.     ccathex(cptr, 0, 4, 4, rct.top);
  952.     ccat   (cptr, ",$");
  953.     ccathex(cptr, 0, 4, 4, rct.left);
  954.     ccat   (cptr, ",$");
  955.     ccathex(cptr, 0, 4, 4, rct.bottom);
  956.     ccat   (cptr, ",$");
  957.     ccathex(cptr, 0, 4, 4, rct.right);
  958.     ccat   (cptr, ")");
  959.     ccatchr(cptr, 13, 1);
  960.  
  961.     ccat   (cptr, "  stdState      = ($");
  962.     rct = (*frHndl)->d.doc.fhInfo.stdState;
  963.     ccathex(cptr, 0, 4, 4, rct.top);
  964.     ccat   (cptr, ",$");
  965.     ccathex(cptr, 0, 4, 4, rct.left);
  966.     ccat   (cptr, ",$");
  967.     ccathex(cptr, 0, 4, 4, rct.bottom);
  968.     ccat   (cptr, ",$");
  969.     ccathex(cptr, 0, 4, 4, rct.right);
  970.     ccat   (cptr, ")");
  971.     ccatchr(cptr, 13, 1);
  972.  
  973.     ccat   (cptr, "  userState     = ($");
  974.     rct = (*frHndl)->d.doc.fhInfo.userState;
  975.     ccathex(cptr, 0, 4, 4, rct.top);
  976.     ccat   (cptr, ",$");
  977.     ccathex(cptr, 0, 4, 4, rct.left);
  978.     ccat   (cptr, ",$");
  979.     ccathex(cptr, 0, 4, 4, rct.bottom);
  980.     ccat   (cptr, ",$");
  981.     ccathex(cptr, 0, 4, 4, rct.right);
  982.     ccat   (cptr, ")");
  983.     ccatchr(cptr, 13, 1);
  984.  
  985.     ccat   (cptr, "  hDocSize      = ");
  986.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.hDocSize);
  987.     ccatchr(cptr, 13, 1);
  988.  
  989.     ccat   (cptr, "  vDocSize      = ");
  990.     ccatdec(cptr, (*frHndl)->d.doc.fhInfo.vDocSize);
  991.     ccatchr(cptr, 13, 1);
  992.  
  993.     HSetState((Handle)frHndl, hstate);
  994. }
  995.  
  996.  
  997.  
  998.